import CheckCommon from "../../financial-management/check-center/check-common";
import {messages} from "share/common";
import moment from 'moment'

export default {
  getPlaneForm(){
    const startDate = CheckCommon.getNextMonth('',-3,true);
    const endDate = CheckCommon.getNextMonth('',0,true);
    return [
      {
        type: 'select',
        id: 'vendorName',
        label: messages('supplier.key436')/*服务商*/,
        options:[],
      } /*消费商*/,
      {
        type: 'items',
        id: 'dateRange',
        colSpan:9,
        items: [
          {
            type: 'select',
            id:'searchType',
            event:'CHANGE_SELECT',
            label: `${messages('common.date')}:`/*"日期"*/,
            defaultValue:'hlytime',
            colSpan:8,
            options: [
              {
                label: messages('supplier.key563')/*预定日期*/,
                value: 'hlytime'
              },
              {
                label:messages('financial-management.key689')/*起飞日期*/,
                value: 'takeofftime'
              },
            ],
          },
          {
            colSpan:8,
            type: 'date',
            id: 'dateFrom',
            defaultValue:startDate,
            label: ' '
          },
          {
            colSpan:8,
            type: 'date',
            id: 'dateTo',
            defaultValue:endDate,
            label: ' '
          }
        ]
      },
      {
        type:'items',
        id: 'dateRadio',
        colSpan:7,
        items:[
          {
            type: 'radio',
            id:'range',
            event:'CHANGETIME_ORDERCENTER',
            label:' ',
            defaultValue:'threeMonths',
            options: [
              {
                label:messages('financial-management.key106'/*今天*/),
                value: 'today'
              },
              {
                label: messages('financial-management.key690')/*本月*/,
                value: 'oneMonth'
              },
              {
                label: messages('financial-management.key108'/*3个月*/),
                value:'threeMonths'
              },
              {
                label: messages('financial-management.key109'/*1年*/),
                value:'year'
              }],
          }
        ]
      },
      {
        type: 'select',
        label: messages('order-management.key17')/*订单状态*/,
        defaultValue:'All',
        id: 'orderType',
        options:[
          {label:messages('financial-management.key36'/*全部*/),value:'All'},
          {label:messages('financial-management.key110'/*出票*/),value:'TICKETED'},
          {label:messages('financial-management.key111'/*改签*/),value:'REBOOKED'},
          {label:messages('financial-management.key112'/*退票*/),value:'REFUNDED'}
        ],
      },
      {
        type: 'items',
        id: 'orderNor',
        colSpan:9,
        items: [
          {
            type: 'select',
            id:'orderNumber',
            event:'CHANGE_SELECT',
            label: `${messages('financial-management.key134'/*单号*/)}:`,
            defaultValue:'recordId',
            colSpan:8,
            options: [
              {
                label: messages('financial-management.key52'/*订单号*/),
                value: 'recordId'
              },
            ],
          },
          {
            colSpan:16,
            type: 'input',
            id: 'toDefineName',
            label:' '
          }
        ]
      },
      {
        type: 'items',
        id: 'aboutCity',
        colSpan:7,
        items: [
          {type: 'input', id: 'startCityName', label: `${messages('financial-management.key47'/*出发城市*/)}:` },
          {type: 'input', id: 'endCityName', label: `${messages('financial-management.key48'/*到达城市*/)}:`},
        ]
      },
      {
        type: 'input',
        id: 'passengerName',
        label: messages('components.key185'/*乘机人*/)
      },
      {
        type: 'input',
        id: 'booker',
        label: messages('supplier.key438')/*预订人*/,
      },
    ]
  },

  /**
   * 格式化搜所数据
   * @param values searchForm 组件返回的数据
   */
  setPlaneFormParams(values){
    const params = {
      vendorName: values.vendorName || '',// 消费商
      searchType: values.searchType || '',// 时间类型
      dateFrom: values.dateFrom ? moment(values.dateFrom).format('YYYY-MM-DD'): "",
      dateTo: values.dateTo ? moment(values.dateTo).format('YYYY-MM-DD'): "",
      orderType: values.orderType === 'All' ? '' : values.orderType, // 订单状态
      orderId: values.toDefineName || '', // 订单号
      startCityName: values.startCityName || '',// 出发城市
      endCityName: values.endCityName || '',// 到达城市
      passengerName: values.passengerName || '',// 乘机人
      booker: values.booker || '',//预定人
    }

    return params;
  }
}
